﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using Libreria.SIG.Negocio;
using System.Configuration;

public partial class rptAlmuerzosAEntregar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LlenarReporte();
        }
    }
    protected void LinkButtonFilter_Click(object sender, EventArgs e)
    {
        LlenarReporte();
    }
    private void LlenarReporte()
    {
        if (DropDownListFechaDeFiltro.SelectedIndex > 0)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            VentaNegocio vn = new VentaNegocio();
            string cadenaDeConexion = ConfigurationManager.ConnectionStrings["SIG"].ConnectionString;
            DateTime fecha = DateTime.Parse(DropDownListFechaDeFiltro.SelectedValue);
            ReportDataSource datasource = new ReportDataSource("dsAlmuerzosParaEntregar", vn.consultarVentasDelDiaConPersonas(fecha, cadenaDeConexion));
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(datasource);
            ReportViewer1.Visible = true;
        }
        else
        {
            ReportViewer1.Visible = false;
        }
    }
}